package com.axdoc.wallet.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;

import com.axdoc.wallet.dao.IPatientWalletDao;
import com.axdoc.wallet.entity.PatientActivitySubWallet;
import com.axdoc.wallet.entity.PatientActivitySubWalletRecords;
import com.axdoc.wallet.entity.PatientBalanceSubWallet;
import com.axdoc.wallet.entity.PatientBalanceSubWalletRecords;
import com.axdoc.wallet.entity.PatientCouponSubWallet;
import com.axdoc.wallet.entity.PatientCouponSubWalletRecords;
import com.axdoc.wallet.entity.PatientVipSubWallet;
import com.axdoc.wallet.entity.PatientVipSubWalletRecords;
import com.axdoc.wallet.entity.PatientWallet;

@Component("patientWalletDao")
public class PatientWalletDaoImpl implements IPatientWalletDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Override
	public boolean addPatientWallet(PatientWallet patientWallet) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update("insert into patient_wallet(wallet_no,aid,wallet_type,p_no) values(?,?,?,?)",
				new Object[] { patientWallet.getWalletNo(), patientWallet.getAid(), patientWallet.getWalletType(),
						patientWallet.getpNo() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addPatientBalanceSubWallet(PatientBalanceSubWallet patientBalanceSubWallet) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_balance_sub_wallet(wallet_no,m_wallet_no,pay_password,is_allowed_pay,is_allowed_recharge,is_allowed_withdrawal,state,balance,withdrawal_balance_can,withdrawal_balance_wait,aid,forzen_balance) values(?,?,?,?,?,?,?,?,?,?,?,?)",
				new Object[] { patientBalanceSubWallet.getWalletNo(), patientBalanceSubWallet.getmWalletNo(),
						patientBalanceSubWallet.getPayPassword(), patientBalanceSubWallet.getIsAllowedPay(),
						patientBalanceSubWallet.getIsAllowedRecharge(),
						patientBalanceSubWallet.getIsAllowedWithdrawal(), patientBalanceSubWallet.getState(),
						patientBalanceSubWallet.getBalance(), patientBalanceSubWallet.getWithdrawalBalanceCan(),
						patientBalanceSubWallet.getWithdrawalBalanceWait(),patientBalanceSubWallet.getAid(),patientBalanceSubWallet.getForzenBalance() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addPatientActivitySubWallet(PatientActivitySubWallet patientActivitySubWallet) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_activity_sub_wallet(wallet_no,m_wallet_no,activity_number,state,aid) values(?,?,?,?,?)",
				new Object[] { patientActivitySubWallet.getWalletNo(), patientActivitySubWallet.getmWalletNo(),
						patientActivitySubWallet.getActivityNumber(), patientActivitySubWallet.getState(),patientActivitySubWallet.getAid() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addPatientCouponSubWallet(PatientCouponSubWallet patientCouponSubWallet) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_coupon_sub_wallet(wallet_no,m_wallet_no,coupon_number,state,aid) values(?,?,?,?,?)",
				new Object[] { patientCouponSubWallet.getWalletNo(), patientCouponSubWallet.getmWalletNo(),
						patientCouponSubWallet.getCouponNumber(), patientCouponSubWallet.getState(),patientCouponSubWallet.getAid() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addPatientVipSubWallet(PatientVipSubWallet patientVipSubWallet) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_vip_sub_wallet(wallet_no,m_wallet_no,service_number,service_id,state,aid) values(?,?,?,?,?,?)",
				new Object[] { patientVipSubWallet.getWalletNo(), patientVipSubWallet.getmWalletNo(),
						patientVipSubWallet.getServiceNumber(), patientVipSubWallet.getServiceId(),
						patientVipSubWallet.getState(),patientVipSubWallet.getAid() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public PatientWallet queryPatientWalletByAid(String aid) {
		List<PatientWallet> list = new ArrayList<PatientWallet>();
		StringBuffer sql = new StringBuffer();
		sql.append("select * from patient_wallet where aid = ? ");
		list = (List<PatientWallet>) jdbcTemplate.query(sql.toString(), new Object[] { aid }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientWallet pw = new PatientWallet();
				pw.setId(rs.getInt("id"));
				pw.setWalletNo(rs.getString("wallet_no"));
				pw.setAid(rs.getString("aid"));
				pw.setWalletType(rs.getInt("wallet_type"));
				pw.setpNo(rs.getString("p_no"));
				pw.setCreateTime(rs.getTimestamp("create_time"));
				pw.setUpdateTime(rs.getTimestamp("update_time"));
				return pw;
			}
		});
		if(null != list && list.size()>0){
			return list.get(0);
		}
		return null;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public PatientBalanceSubWallet queryPatientBalanceSubWalletByAid(String aid) {
		List<PatientBalanceSubWallet> list = new ArrayList<PatientBalanceSubWallet>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_balance_sub_wallet where aid = ? ");
		list = (List<PatientBalanceSubWallet>) jdbcTemplate.query(sql.toString(), new Object[] { aid }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientBalanceSubWallet subWallet = new PatientBalanceSubWallet();
				subWallet.setId(rs.getInt("id"));
				subWallet.setWalletNo(rs.getString("wallet_no"));
				subWallet.setmWalletNo(rs.getString("m_wallet_no"));
				subWallet.setPayPassword(rs.getString("pay_password"));
				subWallet.setIsAllowedPay(rs.getInt("is_allowed_pay"));
				subWallet.setIsAllowedRecharge(rs.getInt("is_allowed_recharge"));
				subWallet.setIsAllowedWithdrawal(rs.getInt("is_allowed_withdrawal"));
				subWallet.setState(rs.getInt("state"));
				subWallet.setBalance(rs.getInt("balance"));
				subWallet.setWithdrawalBalanceCan(rs.getInt("withdrawal_balance_can"));
				subWallet.setWithdrawalBalanceWait(rs.getInt("withdrawal_balance_wait"));
				subWallet.setCreateTime(rs.getTimestamp("create_time"));
				subWallet.setUpdateTime(rs.getTimestamp("update_time"));
				subWallet.setAid(rs.getString("aid"));
				subWallet.setForzenBalance(rs.getInt("forzen_balance"));
				return subWallet;
			}
		});
		if(null != list && list.size()>0){
			return list.get(0);
		}
		return null;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public PatientActivitySubWallet queryPatientActivitySubWalletByAid(String aid) {
		List<PatientActivitySubWallet> list = new ArrayList<PatientActivitySubWallet>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_activity_sub_wallet where aid = ? ");
		list = (List<PatientActivitySubWallet>) jdbcTemplate.query(sql.toString(), new Object[] { aid }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientActivitySubWallet subWallet = new PatientActivitySubWallet();
				subWallet.setId(rs.getInt("id"));
				subWallet.setWalletNo(rs.getString("wallet_no"));
				subWallet.setmWalletNo(rs.getString("m_wallet_no"));
				subWallet.setActivityNumber(rs.getInt("activity_number"));
				subWallet.setState(rs.getInt("state"));
				subWallet.setCreateTime(rs.getTimestamp("create_time"));
				subWallet.setUpdateTime(rs.getTimestamp("update_time"));
				subWallet.setAid(rs.getString("aid"));
				return subWallet;
			}
		});
		if(null != list && list.size()>0){
			return list.get(0);
		}
		return null;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public PatientCouponSubWallet queryPatientCouponSubWalletByAid(String aid) {
		List<PatientCouponSubWallet> list = new ArrayList<PatientCouponSubWallet>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_coupon_sub_wallet  where aid = ? ");
		list = (List<PatientCouponSubWallet>) jdbcTemplate.query(sql.toString(), new Object[] { aid }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientCouponSubWallet subWallet = new PatientCouponSubWallet();
				subWallet.setId(rs.getInt("id"));
				subWallet.setWalletNo(rs.getString("wallet_no"));
				subWallet.setmWalletNo(rs.getString("m_wallet_no"));
				subWallet.setCouponNumber(rs.getInt("coupon_number"));
				subWallet.setState(rs.getInt("state"));
				subWallet.setCreateTime(rs.getTimestamp("create_time"));
				subWallet.setUpdateTime(rs.getTimestamp("update_time"));
				subWallet.setAid(rs.getString("aid"));
				return subWallet;
			}
		});
		if(null != list && list.size()>0){
			return list.get(0);
		}
		return null;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public PatientVipSubWallet queryPatientVipSubWalletByAid(String aid) {
		List<PatientVipSubWallet> list = new ArrayList<PatientVipSubWallet>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_vip_sub_wallet where aid = ? ");
		list = (List<PatientVipSubWallet>) jdbcTemplate.query(sql.toString(), new Object[] { aid }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientVipSubWallet subWallet = new PatientVipSubWallet();
				subWallet.setId(rs.getInt("id"));
				subWallet.setWalletNo(rs.getString("wallet_no"));
				subWallet.setmWalletNo(rs.getString("m_wallet_no"));
				subWallet.setServiceId(rs.getString("service_id"));
				subWallet.setServiceNumber(rs.getInt("service_number"));
				subWallet.setState(rs.getInt("state"));
				subWallet.setCreateTime(rs.getTimestamp("create_time"));
				subWallet.setUpdateTime(rs.getTimestamp("update_time"));
				subWallet.setAid(rs.getString("aid"));
				return subWallet;
			}
		});
		if(null != list && list.size()>0){
			return list.get(0);
		}
		return null;
	}

	@Override
	public boolean updatePatientBalanceSubWallet(PatientBalanceSubWallet patientBalanceSubWallet) {
		boolean result = false;
		/* 更新实现 */
		int i = jdbcTemplate.update(
				"update patient_balance_sub_wallet set wallet_no=?,m_wallet_no=?,pay_password=?,is_allowed_pay=?,is_allowed_recharge=?,is_allowed_withdrawal=?,state=?,balance=?,withdrawal_balance_can=?,withdrawal_balance_wait=?,forzen_balance=? where id=?",
				new Object[] { patientBalanceSubWallet.getWalletNo(), patientBalanceSubWallet.getmWalletNo(),
						patientBalanceSubWallet.getPayPassword(), patientBalanceSubWallet.getIsAllowedPay(),
						patientBalanceSubWallet.getIsAllowedRecharge(),
						patientBalanceSubWallet.getIsAllowedWithdrawal(), patientBalanceSubWallet.getState(),
						patientBalanceSubWallet.getBalance(), patientBalanceSubWallet.getWithdrawalBalanceCan(),
						patientBalanceSubWallet.getWithdrawalBalanceWait(),patientBalanceSubWallet.getForzenBalance(),patientBalanceSubWallet.getId() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean updatePatientActivitySubWallet(PatientActivitySubWallet patientActivitySubWallet) {
		boolean result = false;
		/* 更新实现 */
		int i = jdbcTemplate.update(
				"update patient_activity_sub_wallet set wallet_no=?,m_wallet_no=?,activity_number=?,state=? where id=?",
				new Object[] { patientActivitySubWallet.getWalletNo(), patientActivitySubWallet.getmWalletNo(),
						patientActivitySubWallet.getActivityNumber(), patientActivitySubWallet.getState(),
						patientActivitySubWallet.getId() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean updatePatientCouponSubWallet(PatientCouponSubWallet patientCouponSubWallet) {
		boolean result = false;
		/* 更新实现 */
		int i = jdbcTemplate.update(
				"update patient_coupon_sub_wallet set wallet_no=?,m_wallet_no=?,coupon_number=?,state=? where id=?",
				new Object[] { patientCouponSubWallet.getWalletNo(), patientCouponSubWallet.getmWalletNo(),
						patientCouponSubWallet.getCouponNumber(), patientCouponSubWallet.getState(),
						patientCouponSubWallet.getId() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean updatePatientVipSubWallet(PatientVipSubWallet patientVipSubWallet) {
		boolean result = false;
		/* 更新实现 */
		int i = jdbcTemplate.update(
				"update patient_vip_sub_wallet set wallet_no=?,m_wallet_no=?,service_number=?,service_id=?,state=? where id=?",
				new Object[] { patientVipSubWallet.getWalletNo(), patientVipSubWallet.getmWalletNo(),
						patientVipSubWallet.getServiceNumber(), patientVipSubWallet.getServiceId(),
						patientVipSubWallet.getState(), patientVipSubWallet.getId() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addBalanceRecords(PatientBalanceSubWalletRecords balance) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_balance_sub_wallet_records(wallet_no,trade_no,trx_no,biz_no,change_amount,change_direction,trx_code,trx_desc,biz_code,biz_desc,uid,channel_id,aid,recorded_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
				new Object[] { balance.getWalletNo(), balance.getTradeNo(), balance.getTrxNo(), balance.getBizNo(),
						balance.getChangeAmount(), balance.getChangeDirection(), balance.getTrxCode(),
						balance.getTrxDesc(), balance.getBizCode(), balance.getBizDesc(), balance.getUid(),
						balance.getChannelId(),balance.getAid(),balance.getRecordedTime() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addCouponRecords(PatientCouponSubWalletRecords coupon) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_coupon_sub_wallet_records(wallet_no,trade_no,trx_no,biz_no,coupon_id,coupon_amount,change_direction,uid,channel_id,aid,recorded_time) values(?,?,?,?,?,?,?,?,?,?,?)",
				new Object[] { coupon.getWalletNo(), coupon.getTradeNo(), coupon.getTrxNo(), coupon.getBizNo(),
						coupon.getCouponId(), coupon.getCouponAmount(), coupon.getChangeDirection(), coupon.getUid(),
						coupon.getChannelId(),coupon.getAid(),coupon.getRecordedTime() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addVipRecords(PatientVipSubWalletRecords vip) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate
				.update("insert into patient_vip_sub_wallet_records(wallet_no,trade_no,trx_no,biz_no,service_id,service_amount,change_direction,uid,channel_id,aid,recorded_time) values(?,?,?,?,?,?,?,?,?,?,?)",
						new Object[] { vip.getWalletNo(), vip.getTradeNo(), vip.getTrxNo(), vip.getBizNo(),
								vip.getServiceId(), vip.getServiceAmount(), vip.getChangeDirection(), vip.getUid(),
								vip.getChannelId(),vip.getAid(),vip.getRecordedTime() });
		if (i > 0) {
			result = true;
		}
		return result;
	}

	@Override
	public boolean addActivityRecords(PatientActivitySubWalletRecords activity) {
		boolean result = false;
		/* 插入实现 */
		int i = jdbcTemplate.update(
				"insert into patient_activity_sub_wallet_records(wallet_no,trade_no,trx_no,biz_no,activity_id,activity_amount,change_direction,uid,channel_id,aid,recorded_time) values(?,?,?,?,?,?,?,?,?,?,?)",
				new Object[] { activity.getWalletNo(), activity.getTradeNo(), activity.getTrxNo(), activity.getBizNo(),
						activity.getActivityId(), activity.getActivityAmount(), activity.getChangeDirection(),
						activity.getUid(), activity.getChannelId(),activity.getAid(),activity.getRecordedTime() });
		if (i > 0) {
			result = true;
		}
		return result;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<PatientBalanceSubWalletRecords> queryBalanceRecords(String tradeNo, Timestamp startTime,
			Timestamp endTime) {
		List<PatientBalanceSubWalletRecords> list = new ArrayList<PatientBalanceSubWalletRecords>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_balance_sub_wallet_records where trade_no = ? ");
		list = (List<PatientBalanceSubWalletRecords>) jdbcTemplate.query(sql.toString(), new Object[] { tradeNo }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientBalanceSubWalletRecords record = new PatientBalanceSubWalletRecords();
				record.setId(rs.getInt("id"));
				record.setWalletNo(rs.getString("wallet_no"));
				record.setTradeNo(rs.getString("trade_no"));
				record.setTrxNo(rs.getString("trx_no"));
				record.setBizNo(rs.getString("biz_no"));
				record.setChangeAmount(rs.getInt("change_amount"));
				record.setChangeDirection(rs.getInt("change_direction"));
				record.setTrxCode(rs.getString("trx_code"));
				record.setTrxDesc(rs.getString("trx_desc"));
				record.setBizCode(rs.getString("biz_code"));
				record.setBizDesc(rs.getString("biz_desc"));
				record.setUid(rs.getString("uid"));
				record.setChannelId(rs.getString("channel_id"));
				record.setCreateTime(rs.getTimestamp("create_time"));
				record.setUpdateTime(rs.getTimestamp("update_time"));
				record.setAid(rs.getString("aid"));
				return record;
			}
		});
		return list;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<PatientCouponSubWalletRecords> queryCouponRecords(String tradeNo, Timestamp startTime,
			Timestamp endTime) {
		List<PatientCouponSubWalletRecords> list = new ArrayList<PatientCouponSubWalletRecords>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_coupon_sub_wallet_records where trade_no = ? ");
		list = (List<PatientCouponSubWalletRecords>) jdbcTemplate.query(sql.toString(), new Object[] { tradeNo }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientCouponSubWalletRecords record = new PatientCouponSubWalletRecords();
				record.setId(rs.getInt("id"));
				record.setWalletNo(rs.getString("wallet_no"));
				record.setTradeNo(rs.getString("trade_no"));
				record.setTrxNo(rs.getString("trx_no"));
				record.setBizNo(rs.getString("biz_no"));
				record.setCouponId(rs.getString("coupon_id"));
				record.setCouponAmount(rs.getInt("coupon_amount"));
				record.setChangeDirection(rs.getInt("change_direction"));
				record.setUid(rs.getString("uid"));
				record.setChannelId(rs.getString("channel_id"));
				record.setCreateTime(rs.getTimestamp("create_time"));
				record.setUpdateTime(rs.getTimestamp("update_time"));
				record.setAid(rs.getString("aid"));
				return record;
			}
		});
		return list;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<PatientActivitySubWalletRecords> queryActivityRecords(String tradeNo, Timestamp startTime,
			Timestamp endTime) {
		List<PatientActivitySubWalletRecords> list = new ArrayList<PatientActivitySubWalletRecords>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_activity_sub_wallet_records where trade_no = ? ");
		list = (List<PatientActivitySubWalletRecords>) jdbcTemplate.query(sql.toString(), new Object[] { tradeNo }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientActivitySubWalletRecords record = new PatientActivitySubWalletRecords();
				record.setId(rs.getInt("id"));
				record.setWalletNo(rs.getString("wallet_no"));
				record.setTradeNo(rs.getString("trade_no"));
				record.setTrxNo(rs.getString("trx_no"));
				record.setBizNo(rs.getString("biz_no"));
				record.setActivityId(rs.getString("activity_id"));
				record.setActivityAmount(rs.getInt("activity_amount"));
				record.setChangeDirection(rs.getInt("change_direction"));
				record.setUid(rs.getString("uid"));
				record.setChannelId(rs.getString("channel_id"));
				record.setCreateTime(rs.getTimestamp("create_time"));
				record.setUpdateTime(rs.getTimestamp("update_time"));
				record.setAid(rs.getString("aid"));
				return record;
			}
		});
		return list;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<PatientVipSubWalletRecords> queryVipRecords(String tradeNo, Timestamp startTime, Timestamp endTime) {
		List<PatientVipSubWalletRecords> list = new ArrayList<PatientVipSubWalletRecords>();
		StringBuffer sql = new StringBuffer();
		sql.append(
				"select * from patient_vip_sub_wallet_records where trade_no = ? ");
		list = (List<PatientVipSubWalletRecords>) jdbcTemplate.query(sql.toString(), new Object[] { tradeNo }, new RowMapper() {
			@Override
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				PatientVipSubWalletRecords record = new PatientVipSubWalletRecords();
				record.setId(rs.getInt("id"));
				record.setWalletNo(rs.getString("wallet_no"));
				record.setTradeNo(rs.getString("trade_no"));
				record.setTrxNo(rs.getString("trx_no"));
				record.setBizNo(rs.getString("biz_no"));
				record.setServiceId(rs.getString("service_id"));
				record.setServiceAmount(rs.getInt("service_amount"));
				record.setChangeDirection(rs.getInt("change_direction"));
				record.setUid(rs.getString("uid"));
				record.setChannelId(rs.getString("channel_id"));
				record.setCreateTime(rs.getTimestamp("create_time"));
				record.setUpdateTime(rs.getTimestamp("update_time"));
				record.setAid(rs.getString("aid"));
				return record;
			}
		});
		return list;
	}
	
	@Override
	public boolean updateBalanceById(int id, int balance) {
		boolean result = false;
		/* 更新实现 */
		int i = jdbcTemplate.update("update patient_balance_sub_wallet set balance=balance+? where id=?",
				new Object[] { balance, id });
		if (i > 0) {
			result = true;
		}
		return result;
	}

}
